<?
layout("/inc/layout.html",{title:sysTitle}){
?>

<div id="page-wrapper">
      <!--BEGIN TITLE & BREADCRUMB PAGE-->
      <div id="title-breadcrumb-option-demo" class="page-title-breadcrumb">
          <div class="page-header pull-left">
              <div class="page-title">热搜词设置 </div>
          </div>
          <ol class="breadcrumb page-breadcrumb pull-left">
              <li><i class="fa fa-home"></i>&nbsp;<a href="main.html">首页</a>&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
              <li>统一检索管理&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
              <li class="active">热搜词设置 </li>
          </ol>
           
          <div class="clearfix"></div>
      </div>
      <!--END TITLE & BREADCRUMB PAGE-->
      <!--BEGIN CONTENT-->
      <div class="page-content">
      <div class="row mbl">
           <div class="col-lg-6">
               <div class="input-group input-group-sm mbs">
               <span>
               <table style="width: 95%;">
					<tr height='50'>
						<td align="right">词名称&nbsp;&nbsp;</td>
						<td>
							<input type="text" class="form-control" style="width: 100%;" id="nameZh" name="nameZh" />
						</td>
					</tr>
				</table>
                   </span>
                   <span class="input-group-btn">
                   	<button type="button" style="margin-right: 10px;" data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="hotwordsList()">搜索</button>
                   	<button type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="hotwordsqk()">清空筛选</button>
                   </span>
               </div>
           </div>
           <div class="col-lg-6">
           <div class="tb-group-actions pull-right">
                	<button class="btn btn-sm btn-primary" onclick="importfrom('0')">发布</button>&nbsp;&nbsp;
                	<button class="btn btn-sm btn-primary" onclick="hotwordsvisual()">可视化浏览</button>&nbsp;&nbsp;
                   <button class="btn btn-sm btn-primary" onclick="hotwordsAddUpalod(0)">增加</button>
               </div>
           </div>
       </div>
 
      <table class="table table-hover table-striped table-bordered table-advanced tablesorter mbn">
            <thead>
                <tr>                 
                    <th  style="text-align:center">序号</th>
                    <th  style="text-align:center">词名称</th>
                    <th  style="text-align:center">链接地址</th>
                    <th  style="text-align:center">颜色</th>
                    <th  style="text-align:center">字体大小</th>
                    <th  style="text-align:center">排序</th>
                    <th  style="text-align:center">可操作</th>
                </tr>
            </thead>
            <tbody id="newspaperls"></tbody>
        </table>
		<div id="dataNull" class="panel-body" style="height: 90px; line-height: 50px;" align="center">
				<span class='subtitle' style="font-size: 15px;">数据为空!</span>
		</div>
        <div id="page1" style="text-align: center; margin-top: 20px;"></div>
    </div>
                     
    <!--END CONTENT-->
    </div>

  
<?} ?>
<script type="text/javascript">
var curr
$(function(){
	hotwordsList(curr);
})
	var hotwordsId;
	function gethotwordsId() {
		return hotwordsId;
	}
	function getcurr() {
		return curr;
	}
 	//新增和修改
	function hotwordsAddUpalod(hotwordsAddUpalodId) {
		hotwordsId = hotwordsAddUpalodId;
		layer.open({
			type : 2,
			area : [ '600px', '480px' ],
			fix : false, //不固定
			scrollbar : false,
			shadeClose : true,
			title : '排序策略',
			//maxmin : true,  
			move : false,
			skin : 'layui-layer-rim', //加上边框
			btn : [ '保存 ', '关闭' ],
			content : [ "search-hotwordsAddUpload.html", 'no' ],
			yes : function(index, layer) {
				var iframeWin = parent.window[layer.find('iframe')[0]['name']];
				iframeWin.save();
			},
		});
	}
	//查询列表
	function hotwordsList(count){
		curr=count;
		$.ajax({
				type : "post",
				url : "queryhotwordsList.do",
				data : {
					"nameZh":$("#nameZh").val(),
					"page":count || 1
				},
				dataType : "json",
				success : function(data) {
					var str = "";
					var hotwordsmuch;
					for(var j = 0; j < data.length; j++){
						if(data[j].text.length>0){
							$("#dataNull").hide();
						}else{
							$("#dataNull").show();
						}
						for ( var i = 0; i < data[j].text.length; i++) {
							str += "<tr><td align='center'> "
								+ (i + 1)
								+ "</td><td align='center'> <label>"
								+ data[j].text[i].wordName
								+ "</label></td><td align='center'><label >"
								+ data[j].text[i].linkUrl
								+ "</label></td><td align='center'><label >"
								+ data[j].text[i].fontColor
								+ "</label></td><td align='center'>"
								+ data[j].text[i].fontSize
								+ "</label></td><td align='center'>"
								+ data[j].text[i].sort
								+ "</label></td><td align='center'>"
								+ "<button type=\"button\" class=\"btn btn-default btn-xs\"  onclick=\"hotwordsAddUpalod('"
								+ data[j].text[i].id
								+ "')\">"
								+ "修改"
								+ "</button>&nbsp;&nbsp;&nbsp;"
								+ "<button type=\"button\" class=\"btn btn-default btn-xs\"onclick=\"delhotwords('"
								+ data[j].text[i].id
								+ "')\">"
								+ "删除"
								+ "</button>"
								+ "</td></tr>";
						}
						hotwordsmuch=data[j].hotwordsCount;
					}
					$("#newspaperls").html(str);
					laypage({
						cont : document.getElementById('page1'), //容器。值支持id名、原生dom对象，jquery对象,
						pages : hotwordsmuch, //总页数
						skip : true, //是否开启跳页
						skin : 'molv', //加载内置皮肤，也可以直接赋值16进制颜色值，如:#c00
						curr : curr || 1,
						last: hotwordsmuch,
						groups : 6,//连续显示分页数
						jump : function(obj, first) { //触发分页后的回调
							if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
								hotwordsList(obj.curr);
								curr = obj.curr;
							}
						}
					});
				},
				error : function(data) {
					alert("请求失败");
				}
			});
	}
	//删除
	function delhotwords(delhotwordsld) {
		if (confirm("是否确认删除！！")) {
			$.ajax({
				type : "post",
				url : "deleteHotwords.do",
				data : {
					"id" : delhotwordsld
				},
				dataType : "json",
				success : function(data) {
					hotwordsList();
					layer.msg('删除成功');
				},
				error : function(data) {
					alert("请求失败");
				}
			});
		}
	}
	function hotwordsqk(){
		$("#nameZh").val("");
	}
	//可视化
	function hotwordsvisual() {
		layer.open({
			type : 2,
			area : [ '800px', '600px' ],
			fix : false, //不固定
			scrollbar : false,
			shadeClose : true,
			title : '热度可视化',
			//maxmin : true,  
			move : false,
			skin : 'layui-layer-rim', //加上边框
			btn : [ '关闭' ],
			content : [ "search-hotwords-visual.html", 'no' ],
			cancel : function(index) {
			}
		});
	}
</script>